package com.cy.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.dao.Userdao;
import com.cy.pojo.Userdto;
import com.cy.pojo.Userpojo;

@Service
public class LoginService {
	@Autowired
	private Userdao userdao;
	public Integer userLogin(Userdto userdto) {
		String s=userdto.getUserName();
		if(s!=null) {
			if(userdao.coUserName(s)==0) {
				return 0;//数据不存在
			}else if(userdao.selectByUname(s).getPsw().equals(userdto.getPassWord())) {
				System.out.println("密码正确");
				return 1;//密码正确
			}
			else {
				System.out.println("密码错误");
				return -1;
			}
		}
		return 1;
	}
	
	
	
	public Boolean userLogin(Userpojo userpojo) {
		String username = userpojo.getUser();
		Userpojo uformDB = userdao.selectByUname(username);
		
		
		if(uformDB!=null)
			return true;
		else {
			return false;
		}
	}

}
